package com.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RibbitMQConfig {

    /**
     * 创建交换要:扇形交换机，也叫广播
     * @return
     */
    @Bean("s20201_FanoutExchange")
    public FanoutExchange fanoutExchange()
    {
        return new FanoutExchange("s20201_FanoutExchange");
    }


    /**
     * 创建队列1
     * @return
     */
    @Bean("s20201_Queue1")
    public Queue  queue1()
    {
        return new Queue("s20201_Queue1");
    }

    /**
     * 创建队列2
     * @return
     */
    @Bean("s20201_Queue2")
    public Queue  queue2()
    {
        return new Queue("s20201_Queue2");
    }


    @Bean("s20201_FanoutExchange____________s20201_Queue1")
    public Binding binding1()
    {
        return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }

    @Bean("s20201_FanoutExchange____________s20201_Queue2")
    public Binding binding2()
    {
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }
}
